package com.gnerv.pabu.basic.core.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * <p>
 * CMS-文章表 前端控制器
 * </p>
 *
 * @author Gnerv LiGen
 * @since 2019-10-10
 */
@Api(tags = "CMS管理")
@Slf4j
@CrossOrigin
@Controller
@RequestMapping("/api/cms")
public class CmsController {


    @ApiOperation(value = "首页")
    @RequestMapping(value = "", method = RequestMethod.GET)
    public String index() {
        return "cms/index";
    }

    @ApiOperation(value = "栏目内容页")
    @RequestMapping(value = "/catalog/{catalogId}", method = RequestMethod.GET)
    public String catalog(@PathVariable(value = "catalogId") String catalogId) {
        return "cms/catalogList";
    }

    @ApiOperation(value = "文章内容页")
    @RequestMapping(value = "/catalog/{catalogId}/article/list", method = RequestMethod.GET)
    public String catalogArticleList(@PathVariable(value = "catalogId") String catalogId) {
        return "cms/articleList";
    }

    @ApiOperation(value = "文章内容页")
    @RequestMapping(value = "/article/{articleId}", method = RequestMethod.GET)
    public String article(@PathVariable(value = "articleId") String articleId, ModelMap modelMap) {
        modelMap.addAttribute("ArticleId", articleId);
        return "cms/articleDetail";
    }


}
